package cn.iocoder.yudao.module.brokerage.record.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.brokerage.record.message.CommissionCancelMessage;
import cn.iocoder.yudao.module.api.brokerage.record.message.CommissionUnfreezeMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/24
 */
@Slf4j
@Component
public class BrokerageRecordProducer {

    /**
     * 发送 {@link CommissionUnfreezeMessage} 消息
     *
     * @param userId 用户编号
     * @param tradeNo 交易单号
     * @param payPrice 实付金额
     * @param settlementMoney 佣金
     */
    public void sendCommissionUnfreezeMessage(Long userId, String tradeNo, Integer payPrice, Integer settlementMoney) {
        log.info("[sendCommissionUnfreezeMessage][userId({}) tradeNo({}) payPrice({}) money({})]", userId, tradeNo, payPrice, settlementMoney);
        SpringUtil.getApplicationContext().publishEvent(new CommissionUnfreezeMessage(userId, tradeNo, payPrice, settlementMoney));
    }

    /**
     * 发送 {@link CommissionCancelMessage} 消息
     *
     * @param userId 用户编号
     * @param tradeNo 交易单号
     * @param settlementMoney 佣金
     */
    public void sendCommissionCancelMessage(Long userId, String tradeNo, Integer payPrice, Integer settlementMoney) {
        log.info("[sendCommissionCancelMessage][userId({}) tradeNo({}) payPrice({}) settlementMoney({})]", userId, tradeNo, payPrice, settlementMoney);
        SpringUtil.getApplicationContext().publishEvent(new CommissionCancelMessage(userId, tradeNo, payPrice, settlementMoney));
    }

}
